package com.example.demo3.Service;

import com.example.demo3.Entity.StudentInfo;
import com.example.demo3.Mapper.StudentInfoMapper;
import com.example.demo3.Vo.StudentInfoClassInfo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentInfoServiceImpl implements StudentInfoService{

    @Autowired
    private StudentInfoMapper studentInfoMapper;

    @Override
    public List<StudentInfo> getAllStudentInfo(String name) {
        return studentInfoMapper.getAllStudentInfo(name);
    }

    @Override
    public PageInfo<StudentInfoClassInfo> getPageStudentInfoClassInfo(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<StudentInfoClassInfo>allStuAndClassByName = studentInfoMapper.getAllStudentAndClassByName("");
        PageInfo<StudentInfoClassInfo>pageInfo = new PageInfo<>(allStuAndClassByName);
        return pageInfo;
    }

    @Override
    public Integer delStuById(Integer id){
        return 0;
    }

    @Override
    public List<StudentInfoClassInfo> getAllStudentAndClassByName(String stuName) {
        return studentInfoMapper.getAllStudentAndClassByName(stuName);
    }

    @Override
    public Integer deleteByID(Integer stuid) {
        Integer i = studentInfoMapper.deleteByID(stuid);
        return i;
    }


    @Override
    public Integer insertStudentInfo(StudentInfo studentInfo) {
        return studentInfoMapper.insertStudentInfo(studentInfo);
    }

    @Override
    public Integer updateStudentInfo(StudentInfo studentInfo){
        return studentInfoMapper.updateStudentInfo(studentInfo);
    }
}
